package zhcms.framework.dao;

import java.util.LinkedList;
import java.util.List;
import zhcms.framework.GyReplace;
import zhcms.framework.GySplit;

public class GyPlus {

	private String returnS;
	private String currnS;
	
	public GyPlus() {
		returnS="";
	}
	
	public void setContent(String content){
		this.currnS=content;
	}
	
	public void ParsePlus(String gytFrontSeparator,String gytBackSeparator)
	{
		//获取所有的plus标签
		String tempS = this.currnS;
		//tempS = this.gytContent;
		List<String> gytParameterArray = new LinkedList<String>();
		// String[] gytParameterArray=null;
		// 获取变量标签
		GySplit a = new GySplit();
		a.tool(tempS, gytFrontSeparator+"plus:");
		String[] tempContent = a.Show();
		a = null;
		int temp_count = tempContent.length;
		if (temp_count == 0) {
			// 没有这个标签，跳过
		} 
		else 
		{
			for (int i = 1; i < temp_count; i++) {
				GySplit b = new GySplit();
				b.tool(tempContent[i], gytBackSeparator);
				String[] temp_end_array = b.Show();
				b = null;
				gytParameterArray.add(temp_end_array[0]);
				// gytParameterArray[i-1] = temp_end_array[0];
				//System.out.println(temp_end_array[0]);
			}
			
			for (int i = 0; i < gytParameterArray.size(); i++) {
				//System.out.println(gytParameterArray.get(i));
				//对变量进行分析获取相应的内容 插件名称=其他参数，然后从数据库中查找相应的信息
				GySplit c = new GySplit();
				c.tool(gytParameterArray.get(i).toString(), "=");
				String[] tempParameterArray = c.Show();
				c = null;
				String plusname=tempParameterArray[0];
				String plusother=tempParameterArray[1];
				//调用插件解析类，进行解析    
				
				//System.out.println(plusname);
				GyPlusParse gyplus =new GyPlusParse();
				gyplus.setPlusName(plusname);
				gyplus.setPlusOtherName(plusother);
				gyplus.Parse();
				//未添加错误返回
				GyReplace r = new GyReplace();
				tempS = r.replace(tempS, gytFrontSeparator+"plus:" + gytParameterArray.get(i).toString() + gytBackSeparator, gyplus.getPlusReturnS().toString());
				r = null;
			}
			
			
		}

		this.returnS = tempS;
	}
	
	public void ParsePlus(String gytFrontSeparator,String gytBackSeparator,String gytPFrontSeparator,String gytPBackSeparator)
	{
		//获取所有的plus标签
		String tempS = this.currnS;
		//tempS = this.gytContent;
		List<String> gytParameterArray = new LinkedList<String>();
		// String[] gytParameterArray=null;
		// 获取变量标签
		GySplit a = new GySplit();
		a.tool(tempS, gytFrontSeparator+"plus:");
		String[] tempContent = a.Show();
		a = null;
		int temp_count = tempContent.length;
		if (temp_count == 0) {
			// 没有这个标签，跳过
		} 
		else 
		{
			for (int i = 1; i < temp_count; i++) {
				GySplit b = new GySplit();
				b.tool(tempContent[i], gytBackSeparator);
				String[] temp_end_array = b.Show();
				b = null;
				gytParameterArray.add(temp_end_array[0]);
				// gytParameterArray[i-1] = temp_end_array[0];
				//System.out.println(temp_end_array[0]);
			}
			
			for (int i = 0; i < gytParameterArray.size(); i++) {
				//System.out.println(gytParameterArray.get(i));
				//对变量进行分析获取相应的内容 插件名称=其他参数，然后从数据库中查找相应的信息
				GySplit c = new GySplit();
				c.tool(gytParameterArray.get(i).toString(), "=");
				String[] tempParameterArray = c.Show();
				c = null;
				String plusname=tempParameterArray[0];
				String plusother=tempParameterArray[1];
				//调用插件解析类，进行解析    
				
				//System.out.println(plusname);
				GyPlusParse gyplus =new GyPlusParse();
				gyplus.setPlusName(plusname);
				gyplus.setPlusOtherName(plusother);
				gyplus.Parse();
				//未添加错误返回
				GyReplace r = new GyReplace();
				tempS = r.replace(tempS, gytFrontSeparator+"plus:" + gytParameterArray.get(i).toString() + gytBackSeparator, gyplus.getPlusReturnS().toString());
				r = null;
			}
		}

		this.returnS = tempS;
	}

	public String getcurrnS()
	{
		return this.currnS;
	}
	
	public String getreturnS()
	{
		return this.returnS;
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
